package commandPattern;

import java.awt.Color;

import GUI.FuncPanel;

import composite.ObjectItem;

public class ChangeColor implements Command{
	private ObjectItem objectItem;
	public ObjectItem getObjectItem() { return objectItem; }
	public void setObjectItem(ObjectItem objectItem) { this.objectItem = objectItem; }

	Color oldColor, newColor;

	public void execute() {
		oldColor = objectItem.getColor();
		newColor = FuncPanel.current_color;
		objectItem.setColor(newColor);
	}
	
	public void redo() {
		objectItem.setColor(newColor);
	}
	
	public void undo() {
		objectItem.setColor(oldColor);
	}
		
	/** Return a clone of command in state before execution */
	public ChangeColor clone(){
		ChangeColor commandClone = new ChangeColor();
		commandClone.setObjectItem(objectItem);
		return commandClone;
	}
}
